/*获取接口数据的方法*/
import {
  RECEIVE_MENU_TAGS,
  RECEIVE_RECOMMEND,
  RECEIVE_MV,
  RECEIVE_SINGER,
  RECEIVE_ALBUM,
  RECEIVE_TOP_LIST,
  CHANGE_TOP_ID,
  RECEIVE_SONG,
  RECEIVE_MENU_LIST,
  RECEIVE_RADIO_LIST,
  RECEIVE_DIGITAL_ALBUM_LIST,
  RECEIVE_SONG_LYRIC,
  RECEIVE_MENU_DETAIL,
  RECEIVE_ALBUM_DETAIL,
  RECEIVE_COMMENT,
  RECEIVE_SINGER_ALBUM,
  RECEIVE_SINGER_INFO,
  RECEIVE_SINGER_SONG,
  RECEIVE_SINGER_ATTENTION,
  RECEIVE_SINGER_MV,
  RECEIVE_SINGER_FANS_MV,
  RECEIVE_SINGER_SIMILAR,
  RECEIVE_MV_INFO,
  RECEIVE_MV_COMMENT
} from './mutation-types'
import {
  reqMenuTags,
  reqRecommend,
  reqMVDetail,
  reqSingerList,
  reqNewAlbum,
  reqTopList,
  reqSongDetail,
  reqMenuList,
  reqRadioList,
  reqDigitalAlbumList,
  reqSongLyric,
  reqMenuDetail,
  reqAlbumDetail,
  reqComment,
  reqSingerAlbum,
  reqSingerInfo,
  reqSingerSong,
  reqSingerAttention,
  reqSingerMv,
  reqSingerFansMv,
  reqSingerSimilar,
  reqMvInfo,
  reqMvComment
} from '../api/index'
export default {
  //1、异步获取歌单标签
  async getMenuTags({commit}){
    const response=await reqMenuTags();
    const result=response.data;
    // console.log(result.data);
    if(result.message==='ok'){
      const menuTags=result.data;
      commit(RECEIVE_MENU_TAGS,{menuTags});
    }
  },
  //2、异步获取推荐内容
  async getRecommend({commit}){
    const response=await reqRecommend();
    const result=response.data;
    // console.log(result.response);
    if(result.response.code===0){
      const recommend=result.response;
      commit(RECEIVE_RECOMMEND,{recommend})
    }

  },
  //3、异步获取MV内容
  async getMVDetail({commit},info){
     const response=await reqMVDetail(info);
     const result=response.data;
      // console.log(result);
    if(result.message==='ok'){
       const MV=result.data;
       commit(RECEIVE_MV,{MV})
     }
  },
  //4、异步获取singer内容
  async getSingerList({commit},info){
    const response=await reqSingerList(info);
    const result=response.data;
    if(result.message==='ok'){
      const singer=result.data;
      commit(RECEIVE_SINGER,{singer})
    }
  },
  //5、异步获取album内容
  async getAlbum({commit},info){
    const response=await reqNewAlbum(info);
    const result=response.data;
    if(result.message==='ok'){
      const album=result.data;
      commit(RECEIVE_ALBUM,{album});
    }
  },
  //6、异步获取榜单列表对象
  async getTopList({commit},top_id){
    const response=await reqTopList(top_id);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const topList=result.data;
      commit(RECEIVE_TOP_LIST,{topList})
    }
  },
  //7、同步修改榜单的topId
  changeTopId({commit},topId){
    commit(CHANGE_TOP_ID,{topId})
  },
  //8、异步获取歌曲详情
  async getSongDetail({commit},info){
    const response=await reqSongDetail(info);
    const result=response.data;
    if(result.message==='ok'){
      const song=result.data;
      commit(RECEIVE_SONG,{song})
    }
  },
  //9、异步获取歌单详情
  async getMenuList({commit},info){
    const response=await reqMenuList(info);
    const result=response.data;
    if(result.message==='ok'){
      const menuList=result.data;
      commit(RECEIVE_MENU_LIST,{menuList})
    }
  },
  //10、异步获取电台详情
  async getRadioList({commit}){
    const response=await reqRadioList();
    const result=response.data.response.data.data;
    const radioList=result.groupList;
    commit(RECEIVE_RADIO_LIST,{radioList})
  },
  //11、异步获取数字专辑详情
  async getDigitalAlbumList({commit}){
    const response=await reqDigitalAlbumList();
    const result=response.data.response;
    if(result.code===0){
      const digitalAlbumList=result.data;
      commit(RECEIVE_DIGITAL_ALBUM_LIST,{digitalAlbumList})
    }
  },
  //12、异步获取歌曲歌词
  async getSongLyric({commit},song_mid){
    const response=await reqSongLyric(song_mid);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const songLyric=result.data;
      commit(RECEIVE_SONG_LYRIC,{songLyric})
    }
  },
  //13、异步获取歌单详情
  async getMenuDetail({commit},disstid){
    const response=await reqMenuDetail(disstid);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const menuDetail=result.data;
      commit(RECEIVE_MENU_DETAIL,{menuDetail})
    }
  },
  //14、异步获取专辑详情
  async getAlbumDetail({commit},album_mid){
    const response=await reqAlbumDetail(album_mid);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const albumDetail=result.data;
      commit(RECEIVE_ALBUM_DETAIL,{albumDetail})
    }
  },
  //15、异步获取评论详情
  async getComment({commit},info){
    const response=await reqComment(info);
    const result=response.data.response;
    console.log(result);
    if(result.code===0){
      const comment=result;
      commit(RECEIVE_COMMENT,{comment})
    }
  },
  //16、异步获取歌手专辑详情
  async getSingerAlbum({commit},info){
    const response=await reqSingerAlbum(info);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const singerAlbum=result.data;
      commit(RECEIVE_SINGER_ALBUM,{singerAlbum})
    }
  },
  //17、异步获取歌手详情
  async getSingerInfo({commit},singer_mid){
    const response=await reqSingerInfo(singer_mid);
    const result=response.data;
    // console.log(result);
    if(result.message==='ok'){
      const singerInfo=result.data;
      commit(RECEIVE_SINGER_INFO,{singerInfo})
    }
  },
  //18、异步获取歌手歌曲详情
  async getSingerSong({commit},info){
    const response=await reqSingerSong(info);
    const result=response.data;
    if(result.message==='ok'){
      const singerSong=result.data;
      commit(RECEIVE_SINGER_SONG,{singerSong})
    }
  },
  //19、异步获取歌手关注度详情
  async getSingerAttention({commit},singer_mid){
    const response=await reqSingerAttention(singer_mid);
    const result=response.data;
    if(result.message==='ok'){
      const singerAttention=result.data;
      commit(RECEIVE_SINGER_ATTENTION,{singerAttention})
    }
  },
  //20、异步获取歌手MV详情
  async getSingerMv({commit},info){
    const response=await reqSingerMv(info);
    const result=response.data;
    if(result.message==='ok'){
      const singerMv=result.data;
      commit(RECEIVE_SINGER_MV,{singerMv})
    }
  },
  //21、异步获取歌手粉丝Mv详情
  async getSingerFansMv({commit},info){
    const response=await reqSingerFansMv(info);
    const result=response.data;
    if(result.message==='ok'){
      const singerFansMv=result.data;
      commit(RECEIVE_SINGER_FANS_MV,{singerFansMv})
    }
  },
  //22、异步获取相似歌手列表
  async getSingerSimilar({commit},info){
    const response=await reqSingerSimilar(info);
    const result=response.data;
    if(result.message==='ok'){
      const singerSimilar=result.data.list;
      commit(RECEIVE_SINGER_SIMILAR,{singerSimilar})
    }
  },
  //23、异步获取MV详情对象
  async getMvInfo({commit},mv_mid){
    const response=await reqMvInfo(mv_mid);
    const result=response.data;
    if(result.message==='ok'){
      const mvInfo=result.data;
      commit(RECEIVE_MV_INFO,{mvInfo})
    }
  },
  //24、异步获取MV评论详情对象
  async getMvComment({commit},info){
    const response=await reqMvComment(info);
    const result=response.data;
    if(result.message==='ok'){
      const mvComment=result.data;
      commit(RECEIVE_MV_COMMENT,{mvComment})
    }
  }
}
